//
//  NSObject+Singleton.m
//  HeartWorld
//
//  Created by zhangji on 2016/10/18.
//  Copyright © 2016年 谭明权. All rights reserved.
//

#import "NSObject+Singleton.h"

@implementation NSObject (Singleton)

/*
 将模型中字端为空的数据变成 暂无数据
 */
- (NSArray*)cl_TranModelArray:(NSArray*)array modelName:(NSString*)modelName
{
    Class Modelclass = NSClassFromString(modelName);
    for (id model in array) {
        unsigned int count = 0 ;
        Ivar * ivars =class_copyIvarList([Modelclass class], &count);
        for (unsigned int i = 0; i<count; i++) {
            Ivar ivar= ivars[i];
            const char * type = ivar_getTypeEncoding(ivar);
            NSString* ivarType=[NSString stringWithFormat:@"%s",type];
            if ([ivarType containsString:@"NSString"]) {
                if (!object_getIvar(model, ivar)||[object_getIvar(model, ivar) isEqualToString:@""]) {
                    object_setIvar(model, ivar, @"暂无数据");
                }
            }
        }
        
    }
    return array;
}

/*
 将模型中字端为空的数据变成 暂无数据
 */
- (id)cl_TranModelDic:(id)model modelName:(NSString*)modelName
{
    Class Modelclass = NSClassFromString(modelName);
    unsigned int count = 0 ;
    Ivar * ivars =class_copyIvarList([Modelclass class], &count);
    for (unsigned int i = 0; i<count; i++) {
        Ivar ivar= ivars[i];
        const char * type = ivar_getTypeEncoding(ivar);
        NSString* ivarType=[NSString stringWithFormat:@"%s",type];
        if ([ivarType containsString:@"NSString"]) {
            if (!object_getIvar(model, ivar)||[object_getIvar(model, ivar) isEqualToString:@""]) {
                object_setIvar(model, ivar, @"暂无数据");
            }
        }
    }
    return model;
}

+ (id)sharedInstance
{
    return nil;
}

- (id)sharedInstance
{
    return nil;
}



@end
